package cn.item.buckle.business.pojo;

import cn.item.buckle.confg.ConfigEnum;

import java.io.Serializable;

public class MonitorCarSpeedCount implements Comparable, Serializable {
	private static final long serialVersionUID = -1298531058668317973L;

	private long taskId;
	private String monitorId;
	private int high;
	private int medium;
	private int normal;
	private int low;

	public void addSpeed(int speed) {
		if (speed >= ConfigEnum.MONITOR_CAR_SPEED_HIGH.getIntValue()) {
			++high;
		} else if (speed >= ConfigEnum.MONITOR_CAR_SPEED_MEDIUM.getIntValue()) {
			++medium;
		} else if (speed >= ConfigEnum.MONITOR_CAR_SPEED_NORMAL.getIntValue()) {
			++normal;
		} else {
			++low;
		}
	}

	public long getTaskId() {
		return taskId;
	}

	public void setTaskId(long taskId) {
		this.taskId = taskId;
	}

	public String getMonitorId() {
		return monitorId;
	}

	public void setMonitorId(String monitorId) {
		this.monitorId = monitorId;
	}

	public int getHigh() {
		return high;
	}

	public void setHigh(int high) {
		this.high = high;
	}

	public int getMedium() {
		return medium;
	}

	public void setMedium(int medium) {
		this.medium = medium;
	}

	public int getNormal() {
		return normal;
	}

	public void setNormal(int normal) {
		this.normal = normal;
	}

	public int getLow() {
		return low;
	}

	public void setLow(int low) {
		this.low = low;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		MonitorCarSpeedCount that = (MonitorCarSpeedCount) o;
		return high == that.high &&
				medium == that.medium &&
				normal == that.normal &&
				low == that.low;
	}


	public static void main(String[] args) {
		MonitorCarSpeedCount m1 = new MonitorCarSpeedCount();
		m1.setHigh(0);
		m1.setMedium(3);
		m1.setNormal(2);
		m1.setLow(1);
		MonitorCarSpeedCount m2 = new MonitorCarSpeedCount();
		m2.setHigh(0);
		m2.setMedium(3);
		m2.setNormal(1);
		m2.setLow(4);
		System.out.println(m1.hashCode());
		System.out.println(m2.hashCode());
	}

	@Override
	public int compareTo(Object o) {
		MonitorCarSpeedCount m = (MonitorCarSpeedCount) o;
		int i = Integer.compare(this.high, m.getHigh());
		if (i == 0) {
			i = Integer.compare(this.medium, m.getMedium());
			if (i == 0) {
				i = Integer.compare(this.normal, m.getNormal());
				if (i == 0) {
					return Integer.compare(this.low, m.getLow());
				}
			}
		}
		return i;
	}
}
